0% found this document useful (0 votes)
8 views2 pages

Basics of C

Uploaded by

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

Basics of C

Uploaded by

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

//NoorLal

//221370151
#include <stdio.h>
#include <string.h>

int main()
{
//Mannual 2 (a) task 4
float fahrenheit, celsius;
printf("Enter temperature in Fahrenheit: ");
scanf("%f", &fahrenheit);
celsius = (fahrenheit - 32) * 5 / 9;
printf("Temperature in Celsius: %f\n", celsius);

//Mannual 2 (a) task 5


int number;
float percentage;
printf("Enter a number: ");
scanf("%d", &number);
percentage = number * 0.25;
printf("25%% of %d is: %f\n", number, percentage);

//Mannual 2 (a) task 6


int n1,n2,n3;
printf("Enter 1st number: ");
scanf("%d",&n1);
printf("Enter 2nd number: ");
scanf("%d",&n2);
printf("Enter 3rd number: ");
scanf("%d",&n3);
int min = n1;
if(n2<min){
min = n2;
}
if(n3<min){
min = n3;
}
printf("The minimum number is %d\n",min);

//Mannual 2 (b) task 1


int num = 2;
int sum = 0;
while(num<=100){
sum += num;
num +=2;
}
printf("The sum of even numbers upto 100 is %d \n",sum);

//Mannual 2 (b) task 2


int sum1=0;
for(int i=1;i<=10;i++){
sum1 += i;
}
printf("The sum of integers upto 10 is %d\n",sum1);

//Mannual 2 (b) task 3


for(int i = 0; i<=1000;i+=10){
printf("%d \n",i);
}
//Manual 2 (b) task 4
int numerator=1;
int denominator=30;
while(numerator<=30 && denominator>=1){
printf("%d/%d", numerator, denominator);
numerator +=1;
denominator-=1;

if(numerator <= 30){


printf(", ");
}
}

char word[50];
printf("\nEnter a word: ");
scanf("%s", word);
for(int i = 0;word[i] != '\0';i++){
printf("%c\n",word[i]);
}

int length = strlen(word);


for(int i = length ; i>=0;i--){
printf("%c\n", word[i]);
}

return 0;
}

You might also like