String Reversal Program C

In: Science

Submitted By asim81
Words 366
Pages 2
Course Title
Fundamentals of Algorithm

* Write a function which take two integer constants and display the sum, multiplication. If both numbers are less than 100 otherwise if first number is less than 100 and second number is greater than 100 then perform the division. Please note that sum, multiplication and division logic should be in separate function.

#include<stdio.h>
#include<conio.h>

int a,b,x,y;

int sumIt(int x , int y ) { return x + y;
}

int multiplyIt(int x, int y) { return x * y;
}

int devideIt(int x, int y) { return y / x;
}

void displayIt(int a, int b) {

if (a < 100 && b < 100)
{
printf("sum is %d",sumIt(a,b)); printf("\nproduct is %d",multiplyIt(a,b));
} else if (a < 100 && b > 100)
{
printf("Devision is %d",devideIt(a,b));
} else
{
printf("No condition matches so not performing any calcuclation."); }
}

void main()
{
printf("Enter value of a and b:"); scanf("%d %d",&a,&b); displayIt(a,b);

getch();
}

* Write a program which perform following on string data * Reverse * Small to caps * Caps to small * Find a character from string * Replace a character
REVERSE:
#include<stdio.h>

int main(){ char str[50]; char rev[50]; int i=-1,j=0;

printf("Enter any string : "); scanf("%s",str); while(str[++i]!='\0');

while(i>=0) rev[j++] = str[--i];

rev[j]='\0'; printf("\nString Reversal is : %s \n",rev); return 0;
}
SMALL TO CAPS AND CAPS TO SMALL
#include <ctype.h>
#include <stdio.h>

int main(void)
{

char str[80]; int i;

printf("Enter a string: "); gets(str);

for( i = 0; str[ i ]; i++) str[ i ] = toupper( str[ i ] );

printf("%s\n", str); /* uppercase string */

for(i = 0; str[ i…...

Similar Documents

A Piece of String

...LaTasha Smith 16 August 2012 A Piece of String The short story of A Piece of String was written by Guy de Maupassant in 1883. It is a short story based on in my opinion the theory of “guilty until proven innocent”. The moral of the story is that you must tell the truth to maintain a reputation of honesty and gain trust from others, because a reputation of deceit and dishonesty will make people believe you are not trustworthy, so even when you're telling the truth, it is hard for others to believe. The main characters in The Piece of Strings are Maître Hauchecorne, M. Malandain and The Mayor of Goderville. Maître is a peasant, who picks up anything he sees as useful off the ground. The story begins where he is walking through the market and comes across a piece of string. He picks the string up and keeps it for himself. Later, in the Market, Maître Hanchecornes enemy accuses him of stealing someone else's pocketbook. This soon gets around Goderville, and people begin to distrust and dislike Maître Hauchecorne, despite his claim of innocence. Maître Hauchecorne already had a bad reputation with the citizens of Goderville due to his previous lying and over exaggerations and telling unbelievable stories. This is the main reason for the people's reluctance to believe Maître Hauchecorne, although he is telling the truth. The pocketbook is eventually returned, however the town still doesn’t believe his innocence. The pain and heartache that Maitre Hauchecorne suffered...

Words: 270 - Pages: 2

A Piece of String

...David Smith A Piece of String The short story of A Piece of String was written by Guy de Maupassant in 1883. It is a short story based on in my opinion the theory of “guilty until proven innocent”. The moral of the story is that you must tell the truth to maintain a reputation of honesty and gain trust from others, because a reputation of deceit and dishonesty will make people believe you are not trustworthy, so even when you're telling the truth, it is hard for others to believe. The main characters in The Piece of Strings are Maître Hauchecorne, M. Malandain and The Mayor of Goderville. Maître is a peasant, who picks up anything he sees as useful off the ground. The story begins where he is walking through the market and comes across a piece of string. He picks the string up and keeps it for himself. Later, in the Market, Maître Hanchecornes enemy accuses him of stealing someone else's pocketbook. This soon gets around Goderville, and people begin to distrust and dislike Maître Hauchecorne, despite his claim of innocence. Maître Hauchecorne already had a bad reputation with the citizens of Goderville due to his previous lying and over exaggerations and telling unbelievable stories. This is the main reason for the people's reluctance to believe Maître Hauchecorne, although he is telling the truth. The pocketbook is eventually returned, however the town still doesn’t believe his innocence. The pain and heartache that Maitre Hauchecorne suffered because of......

Words: 267 - Pages: 2

String Theory

...Craig Kalucki Comparitive Religion Tues 4-6:50 String theory and Universal Theories If we can take a looks garment from a sweater, and pull one string such as in a cartoon, the sweater will untangle leaving a pile of string on the floor. Basically what this implies is we break down something in its simplest form, and all we have left are tiny bits of string, which is basically similar to “String Theory”. string theory uses a model of one-dimensional strings in place of the particles of quantum physics. These strings, the size of the Planck length vibrate at specific resonant frequencies. The formulas that result from string theory predict more than four dimensions but the extra dimensions are "curled up" within the Planck length. In addition to the strings, string theory contains another type of fundamental object called a brane, which can have many more dimensions. In some "braneworld scenarios," our universe is actually "stuck" inside of a 3-dimensional brane, called a 3-brane. Common Sense tells us we live in a world defined by three spatial dimensions and one dimension of time. Mainly, it only takes three numbers to pinpoint your physical location at any given moment. On Earth, these coordinates break down to longitude, latitude and altitude representing the dimensions of length, width and height (or depth). If we put a time stamp on those coordinates, we are pinpointed in time as well. To strip that down even more, a one-dimensional world would be like...

Words: 1051 - Pages: 5

Strings

...PROGRAMMING TOOLS AND TECHNIQUES-1 String and StringBuffer string • Unlike many other languages that implement strings as character arrays, Java implements strings as objects of type String. • Advantage of creating strings as objects is that String objects can be constructed a number of ways, making it easy to obtain a string when needed. • Once a String object has been created, you cannot change the characters that comprise that string. • You can still perform all types of string operations. The difference is that each time we need an altered version of an existing string, a new String object is created that contains the modifications. The original string is left unchanged. • This approach is used because fixed, immutable strings can be implemented more efficiently than changeable ones. string • For those cases in which a modifiable string is desired, Java provides two options: StringBuffer and StringBuilder. Both hold strings that can be modified after they are created. • The String, StringBuffer, and StringBuilder classes are defined in java.lang. Thus, they are available to all programs automatically. • The String, StringBuffer, and StringBuilder classes are declared final, which means that none of these classes may be subclassed. The String Constructors • The String class supports several constructors. To create an empty String, you call the default constructor. For example, String s = new String(); will create an instance of String with no characters......

Words: 2908 - Pages: 12

To String a Guitar

...To String A Guitar   To String A Guitar The method of putting a new string on a guitar may seem like an easy process, and in fact, it is. Before I begin to enlighten you on the art of strapping on a new string, there are some things you should know about your guitar. I have provided a map of the anatomy of an acoustic guitar with the appropriate terminology. Any time that I use a term associated with the diagram, I will italicize it. Example: The nut of the guitar. There are six strings on this guitar and I will walk you through the installation of the low E string which, in the above diagram, is the furthest to the left. The only items that you will need are a wire cutter, a guitar tuner, and of course, the low E string. This example will also assume that there is not currently a low E string on your guitar. To begin, you want to make sure that you have a good grasp on your guitar so that it remains stable and motion free while at the same time allowing the use of both of your hands. When you are ready, you can direct your attention to the bridge of the guitar where you will find the bridge pins. At this point, remove the bridge pin that is associated with the low E string. (The one furthest to the left on the diagram) Now focus your attention to the low E string that you have and if it is still coiled, you may uncoil it. At one of the ends of the string you shall see a little hollow ball. Take this ball and put it through the bridge of the guitar where you just...

Words: 826 - Pages: 4

C Program

...Introduction to C Program : Define basic terminologies Describe the steps in program planning & development Describe phases in writing a program Explain the steps in C program planning & development Basic terminologies Programming: planning, scheduling or performing a task or an event  Computer Programming: process of planning a sequence of steps for a computer to follow  Computer Program/Program: list of instructions to be performed by a computer or understood by the computer  Steps in Program Planning & Development 1. 2. 3. 4. 5. Identification of the problem Problem Analysis Setting up an Algorithm Coding Running, Testing & Debugging Steps in Program Planning & Development 1. Identification of the problem knowing what the problem is Steps in Program Planning & Development 2.Problem Analysis     Review the problem & understand carefully what you are asked to do Determine what is given(input) and what result/information must be produced(output) Assign names to each input and output Determine the manner of processing that must be done on the input data to come up with desired output Steps in Program Planning & Development 3. Setting up an Algorithm Algorithm: a step-by-step process that if followed performs a specific task. This can be described in 2 ways: 1. natural language 2. graphical forms/notations What Is an Algorithm?  An algorithm is nothing more than a finite list of instructions on how to perform a task...

Words: 653 - Pages: 3

Design and Implement a C# Program That Will Gather Floating Point Numbers

...tutorial http://helpido.com/design-and-implement-a-c-program-that-will-gather-floating-point-numbers-and-determine-the-sum/ ---------------------------------------------------------------- Design and implement a C# program that will gather floating point numbers and determine the sum and average of the data entered. The program should use separate methods for inputting the data, calculating the sum, calculating the average, and displaying the results. A sentinel value should be used to indicate the user has completed entering their numbers. The output should display a message that includes the count of the numbers entered, the sum of the numbers and the average of the numbers. If the sum of the numbers is greater than 100, a warning message should be displayed indicating “values have exceeded a sum 100”. 2. Additional requirements include: a. Be sure to comment your code. b. Include a comprehensive set of application test data that you used to test your program. Your test data can be shown in a table that includes input data, expected output, actual output and pass/fail results from the test. Example application test data: InputExpected OutputActual OutputDid Test Pass? 10.0 20.0 30.0Sum = 60.0 Average = 20.0Sum = 60.0 Average = 20.0Y Additional test cases here. Be sure to test all logic. Submission requirements: Your deliverables include a C# file and a Word document. The C# file should be named Yournamep1.cs. Your word document...

Words: 276 - Pages: 2

C Tutorial

...C Programming Tutorial C PROGRAMMING TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i COPYRIGHT & DISCLAIMER NOTICE  All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at webmaster@tutorialspoint.com ii T able of Contents C Language Overview .............................................................. 1 Facts about C ............................................................................................... 1 Why to use C ? ............................................................................................. 2 C Programs .................................................................................................. 2 C Environment Setup ............................................................... 3 Text Editor ................................................................................................... 3 The C Compiler ................................................

Words: 14106 - Pages: 57

C Programming

...C PROGRAMMING Section 1. Topics: Functions Statements Input Output Variables Introduction The C programming language has been the most popular high level language used for engineering applications for the last 20 years. It shares many common structures with other procedural languages, such as Pascal, and can be used for general purpose programming of a PC. However, it is also particularly good for development of embedded application programs such as those found in phones, video recorders and so forth. The term procedural language refers to the fact that the language uses procedures to do particular tasks such as printing on the screen. In C these procedures are known as functions and are described below. What is so good about a language like C? The basic reason such languages were developed was to make it easier for humans to program computers. The alternative is the language of the computer, i.e., binary codes. Clearly such ‘low-level’ languages are not very appealing for humans, although sometimes necessary for detailed engineering work. (In fact C is often ‘mixed’ with such languages for engineering applications.) C uses words and symbols that are part of, or similar to, normal language. This makes it easier for programmers to develop code. The C code is converted to the machine code by a special program called a compiler. See note 1. But perhaps the most useful thing about such a language is that it provides the developer with a library of......

Words: 3795 - Pages: 16

Probablility of Appeals and Reversals

...Running head: Probability of Appeals and Reversals Probability of Appeals and Reversals Jackson County Judges Debra R. Hunter CSU Global Campus Math 410-Quantitative Business Analysis Jose Romero Instructor 03/08/2015 Probability of Appeals and Reversals Jackson County Judges The Problem Using a problem given to us in our study of Quantitative Business Analysis an excel spreadsheet has been created in order to answer the given questions. Following is the given problem. 1. The probability of cases being appealed in each of the three different courts. 2. The probability of cases being reversed in each of the three different courts. 3. The probability of cases being reversed given an appeal in each of the three different courts. 4. The probability of a case being appealed for each judge. 5. The probability of a case being reversed for each judge. 6. The probability of reversal, given an appeal for each judge. After these six questions have been answered then a ranking of the judges can be accomplished. The numbers being used in each of the calculations is coming from the excel worksheet that is attached. The last question of the given problem follows. Rank the judges within each court for each of the probabilities in 4 - 6. Then, find the sum of the ranks and get an overall ranking for each judge. Evaluate and discuss the meaning of your results. Results The following results are based on the calculations found...

Words: 2309 - Pages: 10

Strings - Java

...(Displaying Strings in Uppercase and Lowercase) Write a program that inputs a line of text into char array s[100]. Output the line in uppercase letters and in lowercase letters. Enter a line of text: A line with UPPER- and lowercase LeTters The line in uppercase is: A LINE WITH UPPER- AND LOWERCASE LETTERS The line in lowercase is: a line with upper- and lowercase letters (Converting Strings to Integers for Calculations) Write a program that inputs four strings that represent integers, converts the strings to integers, sums the values and prints the total of the four values. Enter an integer string: 43 Enter an integer string: 77 Enter an integer string: 120 Enter an integer string: 9999 The total of the values is 10239 (Random Sentences) Write a program that uses random number generation to create sentences. The program should use four arrays of pointers to char called article, noun, verb and preposition. The program should create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article and noun. As each word is picked, it should be concatenated to the previous words in an array large enough to hold the entire sentence. The words should be separated by spaces. When the final sentence is output, it should start with a capital letter and end with a period. The program should generate 20 such sentences. The arrays should be filled as follows: The article array should contain......

Words: 1497 - Pages: 6

Lg C Program

... About The Tutorial C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system. C is the most widely used computer language. It keeps fluctuating at number one scale of popularity along with Java programming language, which is also equally popular and most widely used among modern software programmers. Audience This tutorial is designed for software programmers with a need to understand the C programming language starting from scratch. This tutorial will give you enough understanding on C programming language from where you can take yourself to higher level of expertise. Prerequisites Before proceeding with this tutorial, you should have a basic understanding of Computer Programming terminologies. A basic understanding of any of the programming languages will help you in understanding the C programming concepts and move fast on the learning track. Copyright & Disclaimer  Copyright 2014 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however,......

Words: 13419 - Pages: 54

Cis 170 C Ilab 5 of 7 Arrays and Strings

...CIS 170 C iLab 5 of 7 Arrays and Strings To Buy This material Click below link http://www.uoptutors.com/cis-170/cis-170-c-ilab-5-of-7-arrays-and-strings Lab # CIS CIS170C-A5 Lab 5 of 7: Arrays and Strings Lab Overview – Scenario/Summary You will code, build, and execute two programs requiring arrays and strings. First program (Video Game Player Program): Determine the average score for a group of players and then determine who scored below average. Second program (Pig Latin): Convert words in a phrase to pig latin. Learning outcomes: Be able to explain the need for arrays in a program. Be able to determine the appropriate array data type to use in a given program. Be able to write a program that implements arrays. Be able to explain the way memory is allocated for arrays in a program. Be able to explain the fact that arrays are objects in C++. Be able to write a program that implements strings.Deliverables Section Deliverable Points Part A Step 5: Program Listing and Output 20 Part B Step 5: Program Listing and Output 25 Lab Steps Preparation: If you are using the Citrix remote lab, follow the login instructions located on the iLab tab in Course Home. Locate the Visual Studio 2010 icon and launch the application. Lab: Part A: Video Game Player Program Step 1: Requirements Write a program to do the following: In main, declare a PlayerName Array and a Score Array. Declare the size of the arrays to be 100. In the InputData function, input the player......

Words: 1117 - Pages: 5

C Programs

...Exercise Based on basics of c and if else 1. Write a program to print ASCII value of a character entered. 2.Write a program to read a character and if the character entered is a upper case then convert it into lower case and vice versa. 3. Write a program to convert degree Fahrenheit into degree Celsius. 4. Write a program to check whether a number entered is a even number or odd number using switch case statement. 5. Write a program to read month of the year as an integer and print the month name using switch case statement. Exercise based on Loops 1. Write a program to print first 10 natural numbers using while loop, for loop and do while loop. 2. Write a program to calculate the sum of first 10 natural number using while loop, for loop do while loop. 3. Write a program to find the reverse of a number. 4. Write a program to check whether a number is palindrome or not. 5. Write a program to check whether a three digit number is a Armstrong number or not. 6. Write a program to print the numbers from m to n range. 7.write a program to calculate factorial of a number. 8.Write a program to check whether a number is prime or not. 9.Write a program to calculate the sum of digits of a number. 10.Write a program to print the following pattern using loops (a)* (b)1 (c) 1 (d) 0 ** 12 22 12 *** ...

Words: 662 - Pages: 3

C Primer

...Third Edition March 26, 1998 ISBN: 0201824701, 1264 pages C++ Primer Third Edition Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and AddisonWesley was aware of a trademark claim, the designations have been printed in initial capital letters or all capital letters. The authors and publisher have taken care in preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The programs and applications presented in this book have been included for their instructional value. They have been tested with care, but are not guaranteed for any particular purpose. The authors and publisher do not offer any warranties or representations, nor do they accept any liabilities with respect to the programs or applications. The publisher offers discounts on this book when ordered in quantity for special sales. For more information please contact: Corporate, Government, and Special Sales Addison Wesley Longman, Inc. One Jacob Way R Copyright Information Copyright © 1998 by AT&T, Objectwrite, Inc., and José Lajoie e Library of Congress Cataloging-in-Publication Data Lippman, Stanley B. C++ Primer / Stanley B. Lippman, José Lajoie. — 3rd ed. e p.......

Words: 275162 - Pages: 1101