Posts

Showing posts from September, 2022

Write a program that inputs base and height from the user and calculates area of a triangle by using the formula Area = Base Height.

Image
 Program #include <stdio.h> #include <conio.h> float base, height double area clrscr(): printf("Enter base"): scanf("%f", &base) printf("Enter height:"): Scanf(%f"', &height); area 0.5 * base * height printf("Area = %5.2f", area); getch() } Output: void main() Enter base: 10.5 Enter height: 5.4 Area = 28.35

Write a program that inputs name, age and address from the user and displays it on the screen

Image
Program #include <stdio.h> #include <conio.h>> void main() Enter y char name|25].address[30] Enter int age clrscr() printf("Enter your age:") Scanf("%d", &age) printf("Enter your name:"); Scanf(%s", name); printf("Enter your address"); Scanf(%s, address) printr(" Your name Is %s in", name): printf("Your address is %s \n", address), printf("Your age is %d in", age) getch()

Write a program in C language to assign values to different variables at the time of declaration. Print the assigned values on the computer screen.

Image
 Program #include <stdio.h> #include <conio.h void main() int marks = 786 float avg = 89.75; char grade = 'A; clrscr() printf("My total marks are %d In", marks) printf("My average is %2.2f In", avg) printf("My grade is %c", grade); getch() Output: My total marks are 786 My average is 89.75 My grade is A