Professional Documents
Culture Documents
assign1 finupload
assign1 finupload
h>
return (number % 10) * 1000 + ((number / 10) % 10) * 100 + ((number / 100) % 10) * 10 + (number
/ 1000);
int main() {
int choice;
printf("Choose an option:\n");
scanf("%d", &choice);
switch (choice) {
case 107: {
int number;
scanf("%d", &number);
break;
case 108: {
int number;
scanf("%d", &number);
break;
case 109: {
int number;
printf("Enter a three-digit number: ");
scanf("%d", &number);
break;
case 110: {
int number;
scanf("%d", &number);
break;
case 111: {
int number;
scanf("%d", &number);
break;
case 112: {
int number;
scanf("%d", &number);
break;
case 113: {
int number;
scanf("%d", &number);
break;
case 114: {
int number;
scanf("%d", &number);
break;
default:
printf("Invalid choice!\n");
return 0;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
return (number / 1000) + ((number / 100) % 10) + ((number / 10) % 10) + (number % 10);
int reversed = 0;
while (number != 0) {
number /= 10;
return reversed;
int count = 0;
while (number != 0) {
if (number % 10 == 0) {
count++;
number /= 10;
return count;
}
// Function to count the number of non-decreasing numbers in a range
int count = 0;
int current = i;
current /= 10;
int isNonDecreasing = 1;
isNonDecreasing = 0;
break;
prevDigit = digit;
current /= 10;
if (isNonDecreasing) {
count++;
return count;
int reversed = 0;
number /= 10;
}
int main() {
int choice;
printf("Choose an option:\n");
scanf("%d", &choice);
switch (choice) {
case 115: {
int number;
scanf("%d", &number);
break;
case 116: {
int number;
scanf("%d", &number);
break;
case 117: {
int number;
scanf("%d", &number);
break;
case 118: {
int number;
scanf("%d", &number);
break;
case 119: {
int number;
scanf("%d", &number);
break;
case 120: {
break;
}
case 121: {
int number;
scanf("%d", &number);
if (isPalindrome(number)) {
} else {
break;
default:
printf("Invalid choice!\n");
return 0;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
return atoi(str);
}
// Function to convert integer to string
char str[50];
number /= 10;
return strlen(str);
int isValid = 1;
isValid = 0;
break;
return isValid;
}
int i = 0;
i++;
if (i > 0) {
strcpy(str, &str[i]);
int left = 0;
str[left] = str[right];
str[right] = temp;
left++;
right--;
int n1 = strlen(num1);
int n2 = strlen(num2);
int index = 0;
int i = 0;
finalResult[index] = '\0';
// Function to convert integer array to character array and print using printf
charArray[size] = '\0';
printf("%s\n", charArray);
memset(result, 0, sizeof(result));
if (i < size1) {
if (i < size2) {
printf("Sum: ");
int main() {
int choice;
printf("Choose an option:\n");
printf("132. Convert integer array to character array and print using printf\n");
printf("135. Convert an integer array of up to 50 digits to character array and print using printf\n");
printf("138. Get a main string and sub string, find position of sub string in main string\n");
printf("139. Get a string using gets function and count all words in it\n");
scanf("%d", &choice);
switch (choice) {
case 131: {
int number;
scanf("%d", &number);
printDigitsAsCharacters(number);
break;
case 132: {
convertIntArrayToCharArray(arr, size);
break;
case 133: {
break;
case 134: {
arr[i] %= 10;
convertIntArrayToCharArray(arr, size);
break;
case 135: {
convertIntArrayToCharArray(arr, size);
break;
case 136: {
scanf("%s", num1);
scanf("%s", num2);
addLargeNumbers(num1, num2);
break;
}
case 137: {
int positions[100];
int count = 0;
scanf("%s", mainString);
if (mainString[i] == character) {
positions[count++] = i + 1;
break;
case 138: {
scanf("%s", mainString);
scanf("%s", subString);
if (pos) {
break;
case 139: {
char inputString[100];
int wordCount = 0;
wordCount++;
break;
default:
printf("Invalid choice!\n");
return 0;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
wordCount++;
return wordCount;
result[i] = '0';
int carry = 0;
int i = 0;
i++;
int main() {
int choice;
printf("Choose an option:\n");
printf("139. Write a program to get a string using gets function and count all the words in it\n");
printf("140. Create a link list for the following structure and get user inputs of id, Maths mark,
Science Mark\n");
printf("141. Create a sample link list and insert a new entry before or after a given id\n");
printf("142. Create a doubly linked list and perform insert and delete operations\n");
printf("143. Create a program to implement a stack using linked list with push, pop, and display
operations\n");
printf("144. Create a program to implement a queue using linked list with add, remove, and
display operations\n");
scanf("%d", &choice);
switch (choice) {
case 139: {
char inputString[100];
gets(inputString);
break;
case 140:
// Code for creating a linked list and inputting data (not provided here)
break;
case 141:
// Code for creating a sample linked list and performing insert operations (not provided here)
break;
case 142:
// Code for creating a doubly linked list and performing insert/delete operations (not provided
here)
break;
case 143:
// Code for implementing a stack using linked list (not provided here)
break;
case 144:
// Code for implementing a queue using linked list (not provided here)
break;
case 145: {
char character;
break;
}
case 146: {
char str[50];
scanf("%s", str);
break;
case 147: {
int number;
scanf("%d", &number);
char str[50];
break;
default:
printf("Invalid choice!\n");
return 0;