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

C Programming Student Data Input and Calculations

The document contains multiple C programs that perform various tasks, including collecting student information, converting measurements, calculating total time in seconds, performing arithmetic operations, temperature conversion, and calculating stock profit. Each program prompts the user for input and displays the results based on the calculations performed. The code examples illustrate fundamental programming concepts such as input/output, data types, and basic arithmetic operations.

Uploaded by

Nagul Dark
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 views5 pages

C Programming Student Data Input and Calculations

The document contains multiple C programs that perform various tasks, including collecting student information, converting measurements, calculating total time in seconds, performing arithmetic operations, temperature conversion, and calculating stock profit. Each program prompts the user for input and displays the results based on the calculations performed. The code examples illustrate fundamental programming concepts such as input/output, data types, and basic arithmetic operations.

Uploaded by

Nagul Dark
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

Q.

#include <stdio.h>

int main() {

char name[50], regNo[20], address[100];

int age;

float weight;

double height;

float cgpa;

printf("Enter Name of Student: ");

scanf("%s", name);

printf("Enter Roll Number: ");

scanf("%s", regNo);

printf("Enter Address: ");

scanf("%s", address);

printf("Enter Age in years: ");

scanf("%d", &age);

printf("Enter Weight in kg: ");

scanf("%f", &weight);

printf("Enter Height in meters: ");

scanf("%lf", &height);

printf("Enter CGPA/percentage: ");

scanf("%f", &cgpa);

printf("\nName of Student: %s\n", name);

printf("Roll Number: %s\n", regNo);

printf("Percentage Score Secured: %.1f%%\n", cgpa);

return 0;

}
q.4

#include <stdio.h>

int main() {

char name[50], regNo[20];

float ageYears, cgpa;

int weightGrams, heightCm;

printf("Enter Name of Student: ");

scanf("%s", name);

printf("Enter Roll Number: ");

scanf("%s", regNo);

printf("Enter Age in years: ");

scanf("%f", &ageYears);

printf("Enter Weight in grams: ");

scanf("%d", &weightGrams);

printf("Enter Height in cm: ");

scanf("%d", &heightCm);

printf("Enter CGPA/percentage: ");

scanf("%f", &cgpa);

int ageMonths = (int)(ageYears * 12);

float weightKg = weightGrams / 1000.0;

float heightMeters = heightCm / 100.0;

printf("\nName of Student: %s\n", name);

printf("Roll Number: %s\n", regNo);

printf("Age in months: %d months\n", ageMonths);

printf("Weight in Kilogram: %.0f\n", weightKg);

printf("Height in meters: %.2f\n", heightMeters);

printf("Percentage Score Secured: %.1f%%\n", cgpa);


return 0;

q.5#include <stdio.h>

int main() {

long int hours, minutes, seconds, total;

printf("Input hours: ");

scanf("%ld", &hours);

printf("Input minutes: ");

scanf("%ld", &minutes);

printf("Input seconds: ");

scanf("%ld", &seconds);

total = (hours * 3600) + (minutes * 60) + seconds;

printf("Total: %ld seconds.\n", total);

return 0;

Q.6

#include <stdio.h>

int main() {

int x, y;

long total, p, s;

printf("Enter x: ");

scanf("%d", &x);

printf("Enter y: ");
scanf("%d", &y);

p = x * y;

s = x + y;

total = (s * s) + p * (s - x) * (p + y);

printf("Total = %ld\n", total);

return 0;

Q.7

#include <stdio.h>

int main() {

float celsius, fahrenheit;

printf("Enter temperature in Celsius: ");

scanf("%f", &celsius);

fahrenheit = (celsius * 9 / 5) + 32;

printf("Temperature in Fahrenheit: %.2f\n", fahrenheit);

return 0;

Q.8

#include <stdio.h>

#define CV 32

int main() {

float celsius, fahrenheit;


printf("Enter temperature in Celsius: ");

scanf("%f", &celsius);

fahrenheit = (celsius * 9 / 5) + CV;

printf("Temperature in Fahrenheit: %.2f\n", fahrenheit);

return 0;

Q.9

#include <stdio.h>

int main() {

int shares;

float purchasePrice, currentPrice, profit;

printf("Enter number of shares purchased: ");

scanf("%d", &shares);

printf("Enter purchase price per share: ");

scanf("%f", &purchasePrice);

printf("Enter current price per share: ");

scanf("%f", &currentPrice);

profit = (shares * currentPrice) - (shares * purchasePrice);

printf("You have made a profit of $%.2f dollars since you bought %d shares of this stock.\n", profit,
shares);

return 0;

You might also like