[go: up one dir, main page]

0% found this document useful (0 votes)
22 views11 pages

Assignment 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views11 pages

Assignment 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

//find out the sum of even and odd no.from 1to10.

// 1 2 3 4 5 6 7 8 9 10

#include<stdio.h>

void main()

int i=1,e=0,o=0;

XYZ:

if(i%2==0)

e=e+i ;

else

o=o+i;

i++;

if(i<=10)

goto XYZ;

}
printf("Even Sum:%d\n",e);

printf("Odd Total:%d",o);

//find out the total no of even and odd no. from 1 to 10

// 1 2 3 4 5 6 7 8 9 10

#include<stdio.h>

void main()

int i=1,e=0,o=0;

XYZ:

if(i%2==0)

e=i/2;

else

o=(i+1)/2;
}

i++;

if(i<=10)

goto XYZ;

printf("Even total:%d\n",e);

printf("Odd Total:%d",o);

//Convert a temperature reading in degrees Fahrenheit to degree Celsius, using the formula. C=(5/9) * (f-
32)

#include<stdio.h>

void main()

int f,C;

printf("enter temperature in fahrenheit:");

scanf("%d", &f);

C = (f-32)*5/9;

printf("%d", C);

}
//calculate volume and area of sphere formula using the formula

#include<stdio.h>

void main()

int r;

float a,v;

printf("enter radius:");

scanf("%d", &r);

v = (float)4/3*3.14*r*r*r;

a = 4*3.14*r*r;

printf("volume of sphere:%.2f\n",v);

printf("area of sphere:%.2f\n",a);

}
//Find out the average of First 10 natural no.

// 1 2 3 4 5 6 7 8 9 10

#include<stdio.h>

void main()

int i=1,s=0;

float a;

XYZ:

s=s+i;

i++;

if(i<=10)

goto XYZ;

a = (float)s/10;

printf("sum of first 10 natural no.:%d\n",s);

printf("average of first 10 natural no.:%.2f\n",a);

}
//Input english hindi science marks and print the following format.

#include<stdio.h>

void main()

int eng,math,sci,total;

float percent;

printf("enter english marks:");

scanf("%d", &eng);

printf("enter maths marks:");

scanf("%d", &math);

printf("enter science marks:");

scanf("%d", &sci);

total = eng+math+sci;

percent = total/3.0;

printf("\n\t\tMARKSHEET\n");

printf("--------------------------------\n");

printf("Subject\t\t\tMarks\n");

printf("--------------------------------\n");

printf("English\t\t\t%d\n",eng);

printf("Maths\t\t\t%d\n",math);

printf("Science\t\t\t%d\n",sci);
printf("--------------------------------\n");

printf("%%tage\t\t\t%.2f\n",percent);

printf("total\t\t\t%d\n",total);

printf("--------------------------------\n");

//Print the following sequence:

// X*1+x*3+x*5+x*7……n

#include <stdio.h>

void main() {

int i=1,x,n,s = 0;

printf("Enter the value of x: ");

scanf("%d", &x);

printf("Enter the number of terms (n): ");

scanf("%d", &n);

i = 1;

lmn:

if (i <= 2 * (n - 1))

s = x * i;

i = i+ 2;

goto lmn;

}
printf("Sum of the series: %d\n", s);

// 1 2 4 8 16 32

#include<stdio.h>

void main()

int i=1;

wxz:

printf("%d,",i);

i=i*2;

if(i<=32)

goto wxz;

//6,11,8,13,10,15,12

#include<stdio.h>

void main()

int i=6;

wxz:
printf("%d,",i);

i=i+5;

printf("%d,",i);

i=i-3;

if(i<=12)

goto wxz;

// Convert Temperature F h. to Cel. Vice versa

//F=c*9/5+32

// C=(f-32) * 5/9

#include<stdio.h>

void main()

int f,C;

printf("enter temperature in fahrenheit:");

scanf("%d", &f);

C = (f-32)*5/9;

printf("%d\n", C);

printf("enter temperature in celsius:");


scanf("%d", &C);

f = (C*9/5)+32;

printf("%d\n", f);

//Input two number through keyboard and swap their values without using third variable?

#include<stdio.h>

void main()

int a,b;

printf("enter two number");

scanf("%d %d", &a, &b);

a = a + b;

b = a - b;

a = a - b;

printf("%d %d",a,b);

}
// Input Miles Thru Key Board and convert it into inches, feet & yard?

#include<stdio.h>

void main()

float m,i,f,y;

printf("enter no. of miles:");

scanf("%f", &m);

i = m*63360;

f = m*5280;

y = m*1760;

printf("Inches:%.2f\n",i);

printf("Feet:%.2f\n",f);

printf("Yard:%.2f\n",y);

You might also like