0% found this document useful (0 votes)
9 views6 pages

Individual Assignment

The document contains five C programming tasks: the first asks for two integers and prints all integers between them; the second counts uppercase and lowercase letters in a word; the third calculates circular velocity based on mass and radius; the fourth removes vowels from a given word; and the fifth performs 2x2 matrix multiplication. Each task includes code snippets demonstrating the required functionality. The programs involve user input and output results to the console.
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)
9 views6 pages

Individual Assignment

The document contains five C programming tasks: the first asks for two integers and prints all integers between them; the second counts uppercase and lowercase letters in a word; the third calculates circular velocity based on mass and radius; the fourth removes vowels from a given word; and the fifth performs 2x2 matrix multiplication. Each task includes code snippets demonstrating the required functionality. The programs involve user input and output results to the console.
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
You are on page 1/ 6

Question 1

Write a C program to ask the user to enter two (2) integer values
(represented by X and Y) between 1 and 100, and the program will print to
the console all of the integer values from X to Y inclusive.
#include <stdio.h>

int main() {

int x, y, i;

// Get input from user

printf("Enter two integers X and Y (between 1 and 100): ");

scanf("%d %d", &x, &y);

// Validate input

if (x < 1 || x > 100 || y < 1 || y > 100) {

printf("Invalid input. Please enter numbers between 1 and 100.\n");

return 1; // Exit with an error code

// Print integers from X to Y

printf("Integers from %d to %d:\n", x, y);

if (x <= y) {

for (i = x; i <= y; i++) {

printf("%d ", i);

} else {

for (i = x; i >= y; i--) {

printf("%d ", i);

printf("\n");

return 0;

Question 2
Write a C program to ask the user to enter a word of any length, which will
count the number of uppercase and lowercase letters and print the result to
the console.

#include <stdio.h>

#include <ctype.h>

int main() {

char word[100]; // Assuming a maximum word length of 99 characters

int uppercaseCount = 0, lowercaseCount = 0;

int i = 0;

printf("Enter a word: ");

scanf("%s", word);

while (word[i] != '\0') {

if (isupper(word[i])) {

uppercaseCount++;

} else if (islower(word[i])) {

lowercaseCount++;

i++;

printf("Uppercase letters: %d\n", uppercaseCount);

printf("Lowercase letters: %d\n", lowercaseCount);

return 0;

Question 3
the velocity 𝑣 of a massive object using the formula: 𝑣=√𝐺𝑀𝑟, where
Write a C program with the function CircularVelocity() that will calculate

𝐺=6.6743×10−11. The program must ask the user to enter the value for the
mass 𝑀 and radius 𝑟, and print the result on the console.

#include <stdio.h>

#include <math.h>

double CircularVelocity(double mass, double radius) {

const double G = 6.6743e-11; // Gravitational constant

return sqrt((G * mass) / radius);

int main() {

double mass, radius, velocity;

printf("Enter the mass (M): ");

scanf("%lf", &mass);

printf("Enter the radius (r): ");

scanf("%lf", &radius);

velocity = CircularVelocity(mass, radius);

printf("Circular velocity (v): %lf\n", velocity);

return 0;

Question 4
Write a C program that contains the function RemoveVowel () that will
accept a character array as argument, then print the contents in the array
without vowels. The program must ask the user for the word, store it in the
character array in the main () function, then call RemoveVowel () to process
the data.

#include <stdio.h>

#include <string.h>

void RemoveVowel(char str[]) {

int i, j;

for (i = 0, j = 0; str[i] != '\0'; i++) {

if (str[i] != 'a' && str[i] != 'e' && str[i] != 'i' && str[i] != 'o' && str[i] != 'u' &&

str[i] != 'A' && str[i] != 'E' && str[i] != 'I' && str[i] != 'O' && str[i] != 'U') {

str[j++] = str[i];

str[j] = '\0'; // Null-terminate the modified string

printf("String without vowels: %s\n", str);

int main() {

char word[100];

printf("Enter a word: ");

scanf("%s", word);

RemoveVowel(word);

return 0;

Question 5
Write a C program to calculate the 2x2 matrix multiplication of A and B. The
user must be allowed to enter the float values for all elements in the
matrices A and B. The result is to be printed to the
console.

#include <stdio.h>

int main() {

float a[2][2], b[2][2], result[2][2];

int i, j, k;

// Input matrix A

printf("Enter elements of matrix A:\n");

for (i = 0; i < 2; i++) {

for (j = 0; j < 2; j++) {

scanf("%f", &a[i][j]);

// Input matrix B

printf("Enter elements of matrix B:\n");

for (i = 0; i < 2; i++) {

for (j = 0; j < 2; j++) {

scanf("%f", &b[i][j]);

// Matrix multiplication

for (i = 0; i < 2; i++) {

for (j = 0; j < 2; j++) {

result[i][j] = 0;

for (k = 0; k < 2; k++) {


result[i][j] += a[i][k] * b[k][j];

// Print the result matrix

printf("Resultant matrix (A * B):\n");

for (i = 0; i < 2; i++) {

for (j = 0; j < 2; j++) {

printf("%.2f\t", result[i][j]);

printf("\n");

return 0;

You might also like