Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Title: C+ program
Description: C+ programming for computational technique assigent
Description: C+ programming for computational technique assigent
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
ASSIGNMENT 8
1
...
Y is X + 10 if X is between
10 and 30
...
Otherwise Y is X − 2
...
h>
#include
10
...
otherwise\n");
printf("4
...
A student is awarded Ex grade if he gets more than 90 marks
...
Similarly range for B, C, D and P are 70-79, 60-69, 50-59, and
35-49 respectively
...
Write a
program, which reads marks of a student and prints his grade
...
h>
#include
80
...
60
...
35
...
exit\n");
printf("your choice?\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("\nEnter marks of the student");
scanf("%d",&x);
printf("Marks=%d",x);
printf("Grade is A\n");
break;
case 2:
printf("\nEnter marks of the student");
scanf("%d",&x);
printf("Marks=%d",x);
printf("Grade is B\n");
break;
case 3:
printf("\nEnter marks of the student");
scanf("%d",&x);
printf("Marks=%d",x);
printf("Grade is C\n");
2
break;
case 4:
printf("\nEnter marks of the student");
scanf("%d",&x);
printf("Marks=%d",x);
printf("Grade is D\n");
break;
case 5:
printf("\nEnter marks of the student");
scanf("%d",&x);
printf("Marks=%d",x);
printf("Grade is P\n");
break;
case 6:
printf("\nEnter marks of the student");
scanf("%d",&x);
printf("Marks=%d",x);
printf("Grade is F\n");
break;
case 7:
exit(0);
default:
printf("Wrong choice!\n");
}
}
return 0;
}
3
...
If income is between 5000 and 6000
then tax is 10% of the amount by which the income exceeds 5000
...
If
income is more than 15000 then the tax is 1900 + 30% of the amount by which the income
exceeds 15000
...
g
...
Write a program, which reads income and calculates the income tax
...
h>
#include
x<5000\n");
printf("2
...
6000
...
exit\n");
printf("your choice?\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("\nEnter Income");
scanf("%d",&x);
printf("No income tax\n");
break;
case 2:
printf("\nEnter Income");
scanf("%d",&x);
y=(x-5000)*10/100;
printf("Tax to be paid is:%d\n",y);
break;
case 3:
printf("\nEnter Income");
scanf("%d",&x);
y=100+(x-6000)*20/100;
printf("Tax to be paid is:%d\n",y);
break;
case 4:
printf("\nEnter Income");
scanf("%d",&x);
y=1900+(x-15000)*30/100;
printf("Tax to be paid is:%d\n",y);
break;
case 5:
exit(0);
default:
printf("Wrong choice!\n");
}
}
return 0;
}
4
...
Y = X + 10 if X is 6
...
Y is 2 ∗ X + 4 if X is 12
...
#include
h>
int main()
{
int choice,x,y;
while(1)
{
printf("\n1
...
x=7\n");
printf("3
...
otherwise\n");
printf("5
...
Write a program, which reads three integers X, Y and Z and prints Y + Z if X is 0
...
If X is 2 then Y ∗ Z is printed
...
#include
h>
int main()
{
int choice,x,y,z,s;
while(1)
{
printf("\n1
...
x=7\n");
printf("3
...
x=3\n");
printf("5
...
Write program, which find the sum of first digits
#include
Write program, which finds sum of those numbers whose first digit is 1
#include
Write program, which finds sum of numbers after deleting first digit
...
h>
main( )
{ int n,i,u,v,sum,digit,x;
scanf("%d",&n);
8
sum=0;
for (i=1;i<=n;i++)
{ scanf("%d",&x);
while (x>0)
{
u=x/10;
v=u*10;
x=x-v;
sum=sum+x;
}
}
printf("Answer=%d",sum);
}
4
...
#include
Write program, which finds sum of numbers after incrementing every even digit
...
h>
main( )
{ int n,i,u,v,w,t,sum,digit,x;
scanf("%d",&n);
sum=0;
for (i=1;i<=n;i++)
{ scanf("%d",&x);
{
u=x/10;
v=x%10;
if(u%2==0)
u=u+1;
if(v%2==0)
v=v+1;
x=(u*10)+v;
{
sum=sum+x;}
}
}
printf("Answer=%d",sum);
}
6
...
h>
10
main( )
{ int n,i,u,v,sum,digit,x;
scanf("%d",&n);
sum=0;
for (i=1;i<=n;i++)
{ scanf("%d",&x);
{
u=x/10;
v=x%10;{
if(u>v)
x=u;
else
x=v;}
sum=sum+x;
}
}
printf("Answer=%d",sum);
}
7
...
#include
Write program, which finds the biggest smallest factor
#include
Write program, which reads a number and finds (sum of digits)smallest factor
...
h>
int main(void)
{
int j,sum=0,n,r=0,q,x;
printf("Enter number");
scanf("%d",&n);
for(j=2;j
if(n%j==0)
{
q=j;
break;
}
}
while(n>0){
r=n%10;
sum+=r;
n/=10;}
x=pow(sum,q);
printf("\nThe smallest factor=%d",q);
printf("\nSum=%d",sum);
printf("\nThe computation of%d power%d =%d",sum,q,x);
return 0;
}
13
10
...
Find sum of greatest common divisors of pair of numbers
...
h>
int main(void)
{
int i,j,sum=0,n,arr[100],gcd=0,k=0;
printf("Enter number");
scanf("%d",&n);
for(i=0;i<2*n;i++)
{
scanf("%d",arr+i);
}
for(i=0;i<2*n;i++)
{
i=i+k;
for(j=1;j<=arr[i]&&arr[i+1];j++)
{
if(arr[i]%j==0&&arr[i+1]%j==0)
{
gcd=j;
break;
}
}
sum+=gcd;
gcd=0;
k=1;}
printf("Sum of all gcds=%d",sum-1);
return 0;
}
14
11
...
h>
int main(void)
{
int a,b,c,s=0,p,m=1,q;
printf("Enter a,b and c");
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
for(int i=a;i<=b;i++){
p=i;
q=c;
while(q!=0){
m*=p;
p=p+1;
q=q-1;
}
s+=m;
m=1;
}
printf("\nThe output is%d",s);
return 0;
}
15
12
...
h>
#include