Assignment 5 - Assignment 5 1. Write a program to identify...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Assignment 5 1. Write a program to identify the smallest negative number and largest positive number that can be store in a variable of data type “short int”. Your program MUST use while statement (and break if necessary) only for looping. Call this program positive-negative.c. #include <stdio.h> main() { short int i; short int smallest; short int largest; i = 0; do{ smallest = i--; } while(i < 0); largest = i; printf("The smallest possible number is %d. \nThe largest possible number is %d.\n", smallest, largest); } 2. Write a program to check if a given positive integer is a palindrome or not. A palindrome number is one that reads the same forward and backwards. Your program MUST use while statements only. Call this program palindrome-number.c. #include <stdio.h> int main() { int x, y, z, temp; printf("Please enter a positive number: "); scanf("%d", &x); while (x < 0) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
printf("Incorrect value, please enter a positive number:"); scanf("%d", &x); } y = x; temp = 0; while (y > 0) { z = y%10;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This homework help was uploaded on 04/03/2008 for the course ECE 175 taught by Professor Grubbs during the Spring '08 term at University of Arizona- Tucson.

Page1 / 3

Assignment 5 - Assignment 5 1. Write a program to identify...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online