0% found this document useful (0 votes)
7 views3 pages

Unit 5

The document contains multiple C programming code snippets that demonstrate basic input and output operations. It includes examples for reading integers, performing arithmetic operations, calculating area, and converting miles to kilometers. Additionally, it showcases a multiplication table and calculates total cost based on user input.
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)
7 views3 pages

Unit 5

The document contains multiple C programming code snippets that demonstrate basic input and output operations. It includes examples for reading integers, performing arithmetic operations, calculating area, and converting miles to kilometers. Additionally, it showcases a multiplication table and calculates total cost based on user input.
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/ 3

5.

1
#include <stdio.h>

int main() {
int a;
scanf("%d", &a);
printf("Your number is: %d", a);
}
#include <stdio.h>

int main() {
int a, b;
int sum;
int diff;
scanf("%d", & a);
scanf("%d", & b);
sum = a + b;
diff= a - b;
// Complete the code
printf("Sum is: %d\n",sum);
printf("Difference is: %d",diff);
}
#include <stdio.h>

int main() {

char x[10];

// Take user input in variable x


scanf("%s", x);

// Print greeting
printf("Hello %s",x);
}
5.2
#include <stdio.h>

int main() {
int length, width;
int area;

scanf("%d", &length);
scanf("%d", &width);
area = length * width;
// calculate area and print area

printf("Area of the rectangle is: %d",area);


}
#include <stdio.h>

int main() {
int a;
int square;
int cube;
scanf("%d",&a);
square = a * a;
cube = a * a * a;
// Take a as input and calculate square and cube

printf("Square is: %d\n", square);


printf("Cube is: %d\n", cube);
}
#include <stdio.h>

int main() {
​ // your code goes here
int mile;
int km;
scanf("%d",&mile);
km=1.60*mile;
printf("%d Kilometers",km);
}
#include <stdio.h>

int main() {
​ // your code goes here
int num;
scanf("%d",&num);
printf("%d x 1 = %d\n" , num, num * 1);
printf("%d x 2 = %d\n" , num, num * 2);
printf("%d x 3 = %d\n" , num, num * 3);
printf("%d x 4 = %d\n" , num, num * 4);
printf("%d x 5 = %d\n" , num, num * 5);
printf("%d x 6 = %d\n" , num, num * 6);
printf("%d x 7 = %d\n" , num, num * 7);
printf("%d x 8 = %d\n" , num, num * 8);
printf("%d x 9 = %d\n" , num, num * 9);
printf("%d x 10 = %d\n" , num, num * 10);
return 0;
}

#include <stdio.h>
int main() {
int CostPerItem;
int NumberOfItems;
scanf("%d%d", &CostPerItem, &NumberOfItems);
int TotalCost = CostPerItem * NumberOfItems;
printf("%d", TotalCost);
return 0;
}

You might also like