0% found this document useful (0 votes)
7 views

assignment priyanka

Uploaded by

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

assignment priyanka

Uploaded by

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

assignment 2

ques1. write a program to take two


numbers as input and swap their values.
solution: #include<stdio.h>

int main()

int a,b,c;

printf(" enter number 1");

scanf("%d",&a);

printf("enter number 2);

scanf("%d",&b);

int c=a;

a=b;

b=c;

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

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

return 0;
}

ques 2 write aprogram to take input for


two variables of type float and print
them upto three decimal point and find
the remainder of two float
numbers#include<stdio.h>
#include<math.h>
int main()
{
float a,b;

printf(" enter first value");


scanf("%f",&a);
printf("enter second value");
scanf("%f",&b);
printf("first value %.3f\n",a);
printf("first value%.3f\n",b);

float d;
d=fmod(a,b);
printf("%f",d);

return 0;

}
ques 3 write a program to perform
the following functions on numbers
input by a user
square root of a number
#include<stdio.h>
#include<math.h>
int main()
{
int a,b;
printf("number");
scanf("%d",&a);
b=sqrt(a);
printf("squareroot of a is %d",b);

return 0;

}
power of a number raised to another
number
#include<stdio.h>

#include<math.h>

int main()

int a,b,c;

printf("number");

scanf("%d",&a);

printf("raise to the power");

scanf("%d",&b);

c=pow(a,b);

printf("power of a is %d",c);
return 0;

ques 4 write a program to print ascii value of an alphabet input by user

#include<stdio.h>

int main()

char a;

printf("enter letter");

scanf("%c",&a);

int b=a;

printf("ASCII code=%d",b);

return 0;

You might also like