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

Basic C Programs for Beginners

The document contains basic C programs aimed at performing simple tasks such as calculating the area of a circle, swapping two numbers, converting Fahrenheit to Celsius, and calculating the total amount of money in a piggy bank. Each program includes an aim, algorithm, and the corresponding C code. The programs demonstrate fundamental programming concepts and input/output operations in C.

Uploaded by

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

Basic C Programs for Beginners

The document contains basic C programs aimed at performing simple tasks such as calculating the area of a circle, swapping two numbers, converting Fahrenheit to Celsius, and calculating the total amount of money in a piggy bank. Each program includes an aim, algorithm, and the corresponding C code. The programs demonstrate fundamental programming concepts and input/output operations in C.

Uploaded by

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

Basic c programs

Basic C Programs
Aim:
1.1 - Write a program to calculate the area of a circle
Algorithm:
Accept radius
Print the area of a circle using formula

Program:

#include <stdio.h>
#include <stdlib.h>
int main(){
float radius;
printf("enter radius : ");
scanf("%f",&radius);
printf("the area of circle is %f \n",3.14*radius*radius);
printf("the circumference of circle is %f",3.14*2*radius);
return 0;

aim:
1.2 - Write a program to swap two numbers using a temporary variable

Algorithm:
Accept two numbers
Interchange the values using temporary variable
Print the interchanged values;

Program:

#include <stdio.h>
#include <stdlib.h>
int main(){int a,b;
printf("a = ");
scanf("%d",&a);
printf("b = ");
scanf("%d",&b);
int t=a;
a=b;
b=t;
printf("a = %d ,b = %d",a,b);
}

Aim:

1.3 - Write a program to Convert degrees fahrenheit into celcius

Algorithm:
Accept the temperature in fahrenheit then use the formula to print the temperature in celcius

Program:

//9c/5=f-32
#include <stdio.h>
#include<stdlib.h>
int main(){
float fahreinheit;
float x;

printf("give fahreinheit = ");


scanf("%f",&fahreinheit);
x=(fahreinheit-32.0)*5/9;
printf("the degree in celcius is %f",x);
return 0;
}

Aim:

1.4- Write a program to calculate the total amount of money in the piggybank, given the coins of
Rs.10,Rs.5 and Re.1
Algorithm:
Accept the number of coins
Multiply their values and the add it and print the result

Program:

#include<stdio.h>
#include<stdlib.h>
int main(){
int ten,five,one;
printf("give the number of 10,5,1 coins ");
scanf("%d,%d,%d",&ten,&five,&one);
printf(" your total amoint is %d",ten*10+five*5+one*1);
return 0;
}

You might also like