. Write a Program to print your name.
2. Write a program to perform arithmetic operations such as addition, subtraction, multiplication and division.
3. Write a program to print addition of numbers from 1 to 10.
Answers
Answer:
1.Write a Program to print your name.
#include <stdio.h>
int main()
{
printf("Name : ABC\n");
return(0);
}
2. Write a program to perform arithmetic operations such as addition, subtraction, multiplication and division.
#include <stdio.h>
int main()
{
int first, second, add, subtract, multiply;
float divide;
printf("Enter two integers\n");
scanf("%d%d", &first, &second);
add = first + second;
subtract = first - second;
multiply = first * second;
divide = first / (float)second;
printf("Sum = %d\n", add);
printf("Difference = %d\n", subtract);
printf("Multiplication = %d\n", multiply);
printf("Division = %.2f\n", divide);
return 0;
}
3. Write a program to print addition of numbers from 1 to 10.
# include <stdio.h>
void main( )
{
int n,sum=0,i;
for (i=1; i<=10; i++)
sum=sum+i;
printf(“sum of natural numbers from 1 to 10 is %d\n”,sum);
}